package com.yc.dao;

import com.yc.bean.OrderDetailBean;
import com.yc.commons.DBHelper;
import lombok.Data;

import java.util.List;

@Data
public class OrderDetailDao {

    static DBHelper db=new DBHelper();
    public static Boolean setOrderDetail(int orderid, int foodid, int buyNum, double discountprice) {
        String sql="INSERT INTO tb_order_detail (orderid, foodid, buynum, discountprice, disabled)\n" +
                "VALUES (?, ?, ?,?, 0);";
        int i = db.doUpdate(sql, orderid, foodid, buyNum, discountprice);
        if (i>0){
            return true;
        }
        return false;

    }
    public static List<OrderDetailBean> find() {
        String sql="select * from tb_order_detail where disabled=0";
        try {
            return db.select(OrderDetailBean.class, sql);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

    }
}


